class MapGd {

	map;
	loca;

	constructor(domId, config = {}) {
		this.map = new AMap.Map(domId, Object.assign({
			zoom: 16,
			viewMode: '3D',
			pitch: 62.489,
			rotation: 300.3,
			// mapStyle: 'amap://styles/28f5f1e7774710f2d218ab9ba738b444',
			mapStyle: 'amap://styles/9d89a78e93bd0ee7506030fa35b9de47',
			center: [116.45916, 39.917359],
			showBuildingBlock: false,
		}, config));

		this.loca = new Loca.Container({
			map: this.map
		});
	}

	initIcon(iconConfig) {
		var lightIcon = new AMap.Icon({
			// 图标的取图地址
			image: iconConfig.url || 'https://a.amap.com/Loca/static/loca-v2/demos/images/light.png',
			// 图标所用图片大小
			imageSize: new AMap.Size(iconConfig.width || 40, iconConfig.height || 40),
		});
	}

	addMarker(iconConfig, markerConfig) {
		var pointLight2Marker = new AMap.Marker(Object.assign({
			position: [116.456598, 39.923482, 400],
			icon: this.initIcon(iconConfig),
			anchor: 'bottom-center',
		}, markerConfig));
		this.map.add(pointLight2Marker);
		return pointLight2Marker;
	}
}

export default MapGd;
